package com.cat.model.web.action.api;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.alonew.json.JSONException;
import com.alonew.json.JSONObject;
import com.cat.model.common.model.common.InterviewVO;
import com.cat.model.common.model.common.UserTokenVO;
import com.cat.model.common.util.ErrorCode;
import com.cat.model.dao.mapper.InterviewMapper;
import com.cat.model.dao.mapper.UserInfoMapper;
import com.cat.model.web.action.base.BaseAction;
import com.cat.model.web.bean.InterviewBean;

public class InterviewAction  extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 5398559445945458784L;
	
	private String token;
	private Integer page;
	private Integer size;
	private Integer type;
	
	@Autowired
	private UserInfoMapper userInfoMapper;
	@Autowired
	private InterviewMapper interviewMapper;
	
	public void getInterviewList(){
		if(page==null || size==null){
			print(ErrorCode.PARAM_ERROR.response());
			return;
		}
		JSONObject infoJson = new JSONObject();
		
		List<InterviewVO> interviewVOList=interviewMapper.getInterviewList(type,(page-1)*size, size);
		List<InterviewBean> interviewBeanList=new ArrayList<InterviewBean>();
		for (InterviewVO interviewVO : interviewVOList) {
			InterviewBean interviewBean=new InterviewBean();
			BeanUtils.copyProperties(interviewVO, interviewBean);
			interviewBeanList.add(interviewBean);
		}
		try {
			infoJson.put("result", 0);
			infoJson.put("data", interviewBeanList);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		print(infoJson.toString());
	}
	
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	public Integer getPage() {
		return page;
	}
	public void setPage(Integer page) {
		this.page = page;
	}
	
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getSize() {
		return size;
	}
	public void setSize(Integer size) {
		this.size = size;
	}
	
}
